package com.my.hp_hr.contorller;

import com.my.hp_hr.entity.Leave;
import com.my.hp_hr.service.LeaveService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/leaveGetMsgServlet")
public class LeaveGetMsgServlet extends HttpServlet {
    private LeaveService leaveService = new LeaveService();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        try {
            String id = req.getParameter("id");
            //System.out.println(id);
            Leave leave = leaveService.getLeaveMsg(id);
            //System.out.println(leave);
            req.setAttribute("leave",leave);
            req.getRequestDispatcher("leave_detail.jsp").forward(req,resp);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
